[Core] Support timeout error in requests+aiohttp transports#43201
[Core] Support timeout error in requests+aiohttp transports#43201
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances timeout error handling in the Azure Core SDK by introducing more specific timeout exception types (ServiceRequestTimeoutError and ServiceResponseTimeoutError) to distinguish between connection and read timeout scenarios. The changes affect both synchronous (requests) and asynchronous (aiohttp) transports.
Key Changes:
- Replaced generic
ServiceRequestErrorandServiceResponseErrorwith specific timeout exceptions where applicable - Updated exception handling in transport layers to properly categorize timeout errors
- Refactored exception handling patterns from try-except-reraise to try-finally blocks
- Added comprehensive test coverage for timeout scenarios
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/core/azure-core/azure/core/pipeline/transport/_requests_basic.py | Updated exception handling to use specific timeout error types for read timeouts and connection timeouts in both send() method and StreamDownloadGenerator |
| sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py | Changed asyncio.TimeoutError handling to raise ServiceResponseTimeoutError instead of generic ServiceResponseError |
| sdk/core/azure-core/azure/core/rest/_aiohttp.py | Added comprehensive exception handling in read() method to catch and convert aiohttp exceptions to appropriate Azure Core exceptions |
| sdk/core/azure-core/azure/core/pipeline/_tools.py | Simplified exception handling by replacing try-except-reraise with try-finally pattern |
| sdk/core/azure-core/azure/core/pipeline/_tools_async.py | Simplified exception handling by replacing try-except-reraise with try-finally pattern |
| sdk/core/azure-core/tests/test_basic_transport.py | Added test cases for timeout scenarios in requests transport, covering both connection and response timeouts |
| sdk/core/azure-core/tests/async_tests/test_basic_transport_async.py | Added test cases for timeout scenarios in aiohttp transport, handling version-specific behavior |
| sdk/core/azure-core/tests/test_stream_generator.py | Updated test expectations from requests.exceptions.ConnectionError to ServiceResponseError |
iscai-msft
left a comment
There was a problem hiding this comment.
Looks good to me! I've run our pipeline with these core changes (see here) and linux tests are passing. windows paths are failing bc of path too long since I'm doing a egg install of this git branch, so we can ignore those. Thanks @annatisch!
pvaneck
left a comment
There was a problem hiding this comment.
Can you add a changelog entry?
Fixes #43200